package com.cheng.im.service.protobuilder;

import com.cheng.im.common.bean.msg.ProtoMsgV1;
import com.cheng.im.service.frienship.domain.ImFriendshipRequest;

public class FriendshipRequestBuilder {

    public static ProtoMsgV1.Message build(ImFriendshipRequest friendshipRequest)
    {
        ProtoMsgV1.Message.Builder mb =
                ProtoMsgV1.Message.newBuilder()
                        .setType(ProtoMsgV1.HeadType.FRIENDSHIP_REQUEST)
                        .setAppId(friendshipRequest.getAppId())
                        .setSequence(friendshipRequest.getSequence());

        ProtoMsgV1.FriendshipRequest.Builder builder = ProtoMsgV1.FriendshipRequest.newBuilder();
        builder.setAddSource(friendshipRequest.getAddSource())
                .setAddWording(friendshipRequest.getAddWording())
                .setId(friendshipRequest.getId())
                .setApproveStatus(friendshipRequest.getApproveStatus())
                .setCreateTime(friendshipRequest.getCreateTime())
                .setFrom(friendshipRequest.getFromId())
                .setTo(friendshipRequest.getToId())
                .setRemark(friendshipRequest.getRemark())
                .setReadStatus(friendshipRequest.getReadStatus())
                .setUpdateTime(friendshipRequest.getUpdateTime());

        return mb.setFriendshipRequest(builder).build();
    }
}
